
<?php

class TmpInbound_InboundDetailController extends Zend_Controller_Action
{
	protected $_inboundDetail;
	protected $_inbound;
	
	public function init()
	{
		//tạo đối tượng chính của module
		$this->_inboundDetail = new Admin_Model_InboundDetail();
		$this->_inbound = new Admin_Model_InboundDetail();
	}
	 
	public function ajaxLoadLocationAction()
	{
		//layout
		$this->_helper->layout()->disableLayout();
		
		//lay tham so
		$request=$this->_request;
		$location_warehouse_code=$request->getParam('location_warehouse_code');

		//lay vi tri kho
		$location=new Admin_Model_Location();
		$locations=$location->fetchAllBase("location_warehouse_code='$location_warehouse_code'");
		
		//truyen ra view
		$this->view->array=array(""=>"- Chọn -")+$location->toArray2($locations,"location_code","location_name");
	}
	
	public function ajaxLoadUnitAction()
	{
		//layout
		$this->_helper->layout()->disableLayout();
		
		//lay tham so
		$request=$this->_request;
		$product_code=$request->getParam('product_code');

		//lay vi tri kho
		$unit=new Admin_Model_Unit();
		$sql="
		SELECT unit_code,unit_name
		FROM tbl_product 
			INNER JOIN tbl_unit_change ON product_unit_change_code = unit_change_code
			INNER JOIN tbl_unit ON unit_code = unit_change_unit_code
		WHERE product_code='$product_code' AND unit_change_rate>0
		";
		$units=$unit->queryBase($sql);
		
		//truyen ra view
		$this->view->array=array(""=>"- Chọn -")+$unit->toArray2($units,"unit_code","unit_name");
	}
}